<template>
  <div>
    <h5>索赔附件</h5>
    <div class="w-50 p-4">
      <attach-item v-for="attach of attachs" :key="attach.id" :attach-data="attach"></attach-item>
    </div>
  </div>
</template>

<script>
import AttachItem from '@/bank/components/attach/Item'
import { attachAdapter } from '@/bank/components/attach/index'
export default {
  components: {
    AttachItem,
  },
  props: {
    busId: String,
  },
  data() {
    return {
      attachs: [],
      tableName: 'datum_customer_attachment',
      loading: false,
    }
  },
  computed: {},
  watch: {
    busId: {
      handler: function () {
        this.getData()
      },
      immediate: true,
    },
  },
  created() {},
  mounted() {},
  methods: {
    async getData() {
      if (!this.busId) {
        return
      }
      this.loading = true
      const attachRes = await this.$api.getData(this.$serviceName, this.tableName, {
        'bus_id.eq': this.busId,
      })
      this.loading = false
      this.attachs = (attachRes?.data ?? []).map(attachAdapter)
    },
  },
}
</script>

<style lang="scss" scoped></style>
